/**
 * <copyright>
 * </copyright>
 *
 * $Id$
 */
package de.hwrberlin.remo.model.impl;

import de.hwrberlin.remo.model.ElementState;
import org.eclipse.emf.ecore.EClass;

import org.eclipse.emf.ecore.InternalEObject;
import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.emf.ecore.util.EObjectContainmentWithInverseEList;
import org.eclipse.emf.ecore.util.InternalEList;
import de.hwrberlin.remo.model.Fact;
import de.hwrberlin.remo.model.LinksFromFacts;
import de.hwrberlin.remo.model.RemoModelPackage;
import java.util.Collection;
import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;
import org.eclipse.emf.common.util.EList;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Fact</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link de.hwrberlin.remo.model.impl.FactImpl#getLinksfacts <em>Linksfacts</em>}</li>
 *   <li>{@link de.hwrberlin.remo.model.impl.FactImpl#isValidated <em>Validated</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public abstract class FactImpl extends KnowledgeBaseElementImpl implements Fact {
	/**
	 * The cached value of the '{@link #getLinksfacts() <em>Linksfacts</em>}' containment reference list.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getLinksfacts()
	 * @generated
	 * @ordered
	 */
	protected EList<LinksFromFacts> linksfacts;
	/**
	 * The default value of the '{@link #isValidated() <em>Validated</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #isValidated()
	 * @generated
	 * @ordered
	 */
	protected static final boolean VALIDATED_EDEFAULT = false;
	/**
	 * The cached value of the '{@link #isValidated() <em>Validated</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #isValidated()
	 * @generated
	 * @ordered
	 */
	protected boolean validated = VALIDATED_EDEFAULT;

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected FactImpl() {
		super();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	protected EClass eStaticClass() {
		return RemoModelPackage.Literals.FACT;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<LinksFromFacts> getLinksfacts() {
		if (linksfacts == null) {
			linksfacts = new EObjectContainmentWithInverseEList<LinksFromFacts>(LinksFromFacts.class, this, RemoModelPackage.FACT__LINKSFACTS, RemoModelPackage.LINKS_FROM_FACTS__FACT);
		}
		return linksfacts;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public boolean isValidated() {
		return validated;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setValidated(boolean newValidated) {
		boolean oldValidated = validated;
		validated = newValidated;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, RemoModelPackage.FACT__VALIDATED, oldValidated, validated));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public ElementState checkRule() {
		// TODO: implement this method
		// Ensure that you remove @generated or mark it @generated NOT
		throw new UnsupportedOperationException();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@SuppressWarnings("unchecked")
	@Override
	public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
		switch (featureID) {
			case RemoModelPackage.FACT__LINKSFACTS:
				return ((InternalEList<InternalEObject>)(InternalEList<?>)getLinksfacts()).basicAdd(otherEnd, msgs);
		}
		return super.eInverseAdd(otherEnd, featureID, msgs);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
		switch (featureID) {
			case RemoModelPackage.FACT__LINKSFACTS:
				return ((InternalEList<?>)getLinksfacts()).basicRemove(otherEnd, msgs);
		}
		return super.eInverseRemove(otherEnd, featureID, msgs);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
		switch (featureID) {
			case RemoModelPackage.FACT__LINKSFACTS:
				return getLinksfacts();
			case RemoModelPackage.FACT__VALIDATED:
				return isValidated();
		}
		return super.eGet(featureID, resolve, coreType);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@SuppressWarnings("unchecked")
	@Override
	public void eSet(int featureID, Object newValue) {
		switch (featureID) {
			case RemoModelPackage.FACT__LINKSFACTS:
				getLinksfacts().clear();
				getLinksfacts().addAll((Collection<? extends LinksFromFacts>)newValue);
				return;
			case RemoModelPackage.FACT__VALIDATED:
				setValidated((Boolean)newValue);
				return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eUnset(int featureID) {
		switch (featureID) {
			case RemoModelPackage.FACT__LINKSFACTS:
				getLinksfacts().clear();
				return;
			case RemoModelPackage.FACT__VALIDATED:
				setValidated(VALIDATED_EDEFAULT);
				return;
		}
		super.eUnset(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public boolean eIsSet(int featureID) {
		switch (featureID) {
			case RemoModelPackage.FACT__LINKSFACTS:
				return linksfacts != null && !linksfacts.isEmpty();
			case RemoModelPackage.FACT__VALIDATED:
				return validated != VALIDATED_EDEFAULT;
		}
		return super.eIsSet(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public String toString() {
		if (eIsProxy()) return super.toString();

		StringBuffer result = new StringBuffer(super.toString());
		result.append(" (validated: ");
		result.append(validated);
		result.append(')');
		return result.toString();
	}

} //FactImpl
